#include "wssoft.h"
#include "ui_wssoft.h"
#include "bmc.h"
#include "cpu.h"
#include "gpu.h"
#include "ltp.h"
#include "usb.h"
#include "memory.h"
#include "file.h"
#include "recorddata.h"
#include <QMenu>
#include <QAction>  //主界面菜单栏库
#include <QProcess> //qt外部连接库
#include <QProcess>
#include <QDebug>


WsSoft::WsSoft(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::WsSoft)
{
    ui->setupUi(this);


    m_process = new QProcess;
    m_process->start("bash");
    m_process->waitForStarted();

    connect(m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(readBashStandardOutputInfo()));
    connect(m_process, SIGNAL(readyReadStandardError()), this, SLOT(readBashStandardErrorInfo()));




}
WsSoft::~WsSoft()
{
    delete ui;
}



//终端交互功能

void WsSoft::on_lineEdit_returnPressed()
{
    QString _str = ui->lineEdit->text();
    ui->textBrowser->append("Linux:~$ " + _str);
    m_process->write(ui->lineEdit->text().toLocal8Bit() + '\n');
    ui->lineEdit->clear();
}

void WsSoft::readBashStandardOutputInfo()
{
    QByteArray _out = m_process->readAllStandardOutput();
    if(!_out.isEmpty())   ui->textBrowser->append(QString::fromLocal8Bit(_out));
}

void WsSoft::readBashStandardErrorInfo()
{
    QByteArray _out = m_process->readAllStandardError();
    if(!_out.isEmpty())   ui->textBrowser->append(QString::fromLocal8Bit(_out));
}


//bmc按钮切换页面
void WsSoft::on_bth_BMC_clicked()
{

    Bmc *addb = new Bmc();
    addb ->show();
    this ->close();

}

//CPU按钮切换页面
void WsSoft::on_bth_CPU_clicked()
{

    Cpu *addc = new Cpu();
    addc ->show();
    this ->close();

}
//GPU按钮切换页面
void WsSoft::on_bth_GPU_clicked()
{
    Gpu *addg = new Gpu();
    addg ->show();
    this ->close();
}
//LTP按钮切换页面
void WsSoft::on_bth_LTP_clicked()
{
    Ltp *addl = new Ltp();
    addl ->show();
    this ->close();
}
//USB按钮切换页面
void WsSoft::on_bth_USB_clicked()
{
    Usb *addu = new Usb();
    addu ->show();
    this ->close();
}
//内存按钮切换页面
void WsSoft::on_bth_memory_clicked()
{
    Memory *addm = new Memory();
    addm   ->show();
    this    ->close();
}
//系统文件按钮切换页面
void WsSoft::on_bth_file_clicked()
{
    File  *addf = new File();
    addf   ->show();
    this    ->close();
}

void WsSoft::on_bth_exit_clicked()
{

}
//切换数据表格
void WsSoft::on_bth_RecordDate_clicked()
{
    RecordData *addR = new RecordData();
    addR ->show();
    this ->close();
}


